package com.gusto.engine.semsim.util;

import org.apache.log4j.Logger;

import com.gusto.engine.beans.exceptions.PropertyAccessException;
import com.gusto.engine.beans.model.Res;
import com.gusto.engine.semsim.exceptions.SimilarityException;
import com.gusto.engine.semsim.measures.ResourceSimilarity;

/**
 * <p>Utility for calculating the similarity, and including all the plug-ins.</p>
 * 
 * @author amokrane.belloui@gmail.com
 *
 */
public class SimilarityUtils {
	
	private Logger log = Logger.getLogger(getClass());
	
	/**
	 * Only method that allows calculation of similarities, 
	 * so that it can include plugin's for storing, sending, the information.
	 * @param context
	 * @param resource1
	 * @param resource2
	 * @return
	 * @throws SimilarityException
	 */
	public Double getSimilarity(String context, Res resource1, Res resource2, ResourceSimilarity resSim) throws SimilarityException, PropertyAccessException {
		Double sim = resSim.getSimilarity(resource1, resource2);
		log.info("Similarity " + sim + " '" + context + "' " + resource1 + "-" + resource2);
		return sim;
	}
	
}
